<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/jsp/common/tag_lib.jsp"%>    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
    	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<title>스프링 테스트 예제</title>
		<script type="text/javascript">
		    // jQuery
	        $(document).ready(
	    	    function () {

	    	    }

	    	);

	    	function uploadPhoto() {

	    	    if($("#token").val() == "") { 
		    	    alert("wait a minute");
		    	    return;
	    	    }

	    	    var value = $("#secret").val() 
	    	        + "api_key" + $("#api_key").val()
	    	        + "auth_token" + $("#auth_token").val()
	    	        + "content_type" + $("#content_type").val()
	    	        + "description" + $("#description").val()
	    	        + "hidden" + $("#hidden").val()
	    	        + "is_family" + $("#is_family").val()
	    	        + "is_friend" + $("#is_friend").val()
	    	        + "is_public" + $("#is_public").val()
	    	        + "safety_level" + $("#safety_level").val()
	    	        + "tags" + $("#tags").val()
	    	        + "title" + $("#title").val();

    	        $("#api_sig").val(MD5(value));


    	        // 토큰을 구한다.
    	        var method = "flickr.auth.getToken";
    	        var tokenSig = $("#secret").val() + "api_key" + $("#api_key").val() + "formatjson" + "frob" + $("#frob").val()
    	                + "jsoncallback?" + "method" + method;

    	        // URL 셋팅
    	        var tokenUrl = "http://flickr.com/services/rest/?method=" + method + "&api_key=" + $("#api_key").val()
    	                + "&frob=" + $("#frob").val() +"&api_sig=" + MD5(tokenSig) + "&format=json&jsoncallback=?";

    	        $("#target").append(tokenUrl);
    	        
                //$.getJSON(tokenUrl, 
                //    function(data) {
                //	    for(var key in data ){
                //	        alert(key + " : " + data[key]);
                //		}
                //   }
                //);

                $("#uploadForm").submit();
	    	}

	    	function uploadPhoto2() {
	    	    $("#uploadForm").submit();
	    	}
		</script>
	</head>
	<body>
	    <p>Upload Form</p>
	    <div id="target"></div>
	    <hr/>
	    <p>
	       SECRET : <input type="text" id="secret" name="secret" value="${photo.secret }" /><br />
	       APIKEY : <input type="text" id="api_key" name="api_key" value="${photo.api_key }" /><br />
	       FROB : <input type="text" id="frob" name="frob" value="${photo.frob }" /><br />
	    </p>
	    <form id="uploadForm" action="./create.jude" method="post" enctype="multipart/form-data">
	       TOKEN : <input type="text" id="auth_token" name="auth_token" value="${photo.auth_token }" /><br />
	       APISIG : <input type="text" id="api_sig" name="api_sig" value="" /><br />
	       TITLE : <input type="text" id="title" name="title" value="" /><br />
	       DESC : <input type="text" id="description" name="description" value="" /><br />
	       TAGS : <input type="text" id="tags" name="tags" value="" /><br />
	       IS_PUBLIC : <input type="text" id="is_public" name="is_public" value="1" /><br />
	       IS_FRIEND : <input type="text" id="is_friend" name="is_friend" value="1" /><br />
	       IS_FAMILY : <input type="text" id="is_family" name="is_family" value="1" /><br />
	       SAFETY_LEVEL : <input type="text" id="safety_level" name="safety_level" value="1" /><br />
	       CONTENT_TYPE : <input type="text" id="content_type" name="content_type" value="1" /><br />
	       HIDDEN : <input type="text" id="hidden" name="hidden" value="1" /><br />
	       FILE : <input type="file" id="photo" name="photo" value="" /><br />
	       <input type="button" value="전송" onclick="uploadPhoto2();" />
	    </form>
	</body>
</html>